<%@page import="java.math.BigDecimal"%>
<%@page import="org.springframework.security.core.context.SecurityContextHolder"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="org.apache.commons.lang.time.DateFormatUtils"%>
<%@page import="org.springframework.util.CollectionUtils"%>
<%@page import="java.util.Collection"%>
<%@ include file="../common/common_include.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	UserInfo user = (UserInfo)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
	String username = user.getName();
	String siteid = user.getSiteId();
	
	TblOaAuthRole role = (TblOaAuthRole)request.getAttribute("role");
	String siteId = role.getSiteId();
	List<BigDecimal> permissionIdList = new ArrayList<BigDecimal>();
	if(null!=role){
		if(StringUtils.isNotBlank(role.getPermissionIds())){
			String permissionIdArr[] = role.getPermissionIds().split(",");
			for(String r:permissionIdArr){
				permissionIdList.add(new BigDecimal(r));
			}
		}
	}
	List<TblOaAuthPermission> permissionlist = (List<TblOaAuthPermission> )request.getAttribute("permissionlist");
%>

<style>
	.selectHour-split{
		padding:0 2px;
		margin-right:5px;	
	}
	.selectMinute-split{
		padding:0 2px;
	}
</style>

<div>
	<form id="LeaveAddForm" target="_coreIframe" method="post" action="<%=request.getContextPath()%>/check/doEditRole" enctype="multipart/form-data">
		<div class="breadcrumb">
			<div class="bcIcon"></div>
			<ul class="bcNav">
				<li>修改角色</li>
			</ul>
		</div>
		<table class="formTable">
			<tr>
				<td class="tdTitle">角色名称:</td>
				<td><input class="inputText xs" value="<%=role.getRoleDesc()%>" name="rolename"></td>
			</tr>
			<tr>
				<td class="tdTitle">所属公司：</td>
				<td>
					<select id="siteList" class="easyui-combobox" name="siteid" style="width:100px;"></select>
					<span class="errorTipWrap" id="errorTip_siteid"></span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">权限：</td>
				<td class="" colspan="2">
					<div style="padding-top:10px;padding-bottom:10px;">
						<div class="checkbox-wrap">
							<label>
								<input type="checkbox" class="checkbox checkboxSelectAll">
								<span>全选</span>
							</label>
						</div>
						<div class="checkbox-wrap">
						<%
							if(!CollectionUtils.isEmpty(permissionlist)){
								for(TblOaAuthPermission p :permissionlist){
									%>
										<label class="check-label-role">
											<input type="checkbox"
											 value="<%=EncrypTool.encode(p.getPermissionId()+"")%>" 
											 name="permissioins" 
											 class="checkbox"
											 <%=permissionIdList.contains(p.getPermissionId())?"checked='checked'":""%>
											 >
											<span><%=p.getPermissionName() %></span>
										</label>
									<%
								}
							}
						%>
						</div>
					</div>
				</td>
			</tr>
			<tr>
				<td class="tdTitle"></td>
				<td>
					<div>
						<input class="input-btn-microsoft" type="submit" value="提交">
						<a class="a-btn-microsoft" href="javascript:XF.Setting.listRole()">取消</a>
					</div>
				</td>
			</tr>	
		</table>
		<input type="hidden" value="<%=username %>" name="addUser"> 	
		<input type="hidden" value="<%=EncrypTool.encode(role.getRoleId()+"")%>" name="roleId"> 
	</form>
	<iframe id="_coreIframe" name="_coreIframe" style="display: none;"></iframe>
</div>
<script>
$('#siteList').combobox({
	url:global.contextPath + '/company/siteList',
	valueField:'siteid',
	textField:'sitename',
});
$('#siteList').combobox('setValue', '<%=siteId%>');
XF.Check.init();
XF.Setting.initAddRole();
</script>


